home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Composite_Mix.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.7 KB  |  151 lines

  1. /*
  2. ** $VER: Composite_Mix.ieb 1.21, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 27/1 1997 Stockholm/Sweden
  6. **
  7. ** Mix two images into one with adjustable mix level.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK S2'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xoff=0 ; Yoff=0 ; MixVal=50
  42.  
  43.   if command ~= '' then parse var command Xoff Yoff MixVal '#'Transp
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Composite" " OK | Cancel"',
  48.   ' INTEGER,"X offset",-4096,4096,'Xoff',SLIDER',
  49.   ' INTEGER,"Y offset",-4096,4096,'Yoff',SLIDER',
  50.   ' INTEGER,"Mix value",0,100,'MixVal',SLIDER'
  51.  
  52.   if command = '' then do
  53.     form = form||' CHECKBOX,"Make black transparent? (Genlock)",1'
  54.  
  55.     form
  56.     parse var result ok Xoff Yoff MixVal Transp .
  57.     if ok = 0 then return '<ERROR>'
  58.   end
  59.   else do
  60.     form
  61.     parse var result ok Xoff Yoff MixVal
  62.     if ok = 0 then return '<ERROR>'
  63.  
  64.     Transp = 'none'
  65.   end
  66.  
  67.   back = Xoff Yoff MixVal '#'strip(Transp)
  68. return back
  69.  
  70. /* Required "Process_image" procedure  ------------------------------- */
  71.  
  72. process_image:
  73.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"'
  74.   parse var options Xoff Yoff MixVal '#'Transp .
  75.  
  76.   'OPEN' '"'src_image'"' '24'
  77.   if (RC ~= 0) then do
  78.     'IE_TO_FRONT'
  79.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  80.     return '<ERROR>'
  81.   end
  82.   else LoadImage = result
  83.  
  84.   'OPEN' '"'sec_image'"' '24'
  85.   if (RC ~= 0) then do
  86.     'IE_TO_FRONT'
  87.     'REQUEST' '"Failed to load image:' d2c(10)||sec_image'"' '" OK "'
  88.     return '<ERROR>'
  89.   end
  90.   else SecondImage = result
  91.  
  92.   'PROJECT_INFO' LoadImage 'WIDTH'
  93.   IW = RESULT
  94.   'PROJECT_INFO' LoadImage 'HEIGHT'
  95.   IH = RESULT
  96.  
  97.   'PROJECT_INFO' SecondImage 'WIDTH'
  98.   SIW = RESULT
  99.   'PROJECT_INFO' SecondImage 'HEIGHT'
  100.   SIH = RESULT
  101.  
  102.   if Xoff > SIW then Xoff = SIW
  103.   if Yoff > SIH then Yoff = SIH
  104.  
  105.   if Xoff < (-1)*IW then Xoff = (-1)*IW
  106.   if Yoff < (-1)*IH then Hoff = (-1)*IH
  107.  
  108.   if Transp = 1 then Transp = 'GENLOCK'
  109.   else Transp = ''
  110.  
  111.   'MARK' LoadImage 'PRIMARY'
  112.   'MARK' SecondImage 'SECONDARY'
  113.  
  114.   'COMPOSITE' Xoff Yoff 'MIX' MixVal Transp
  115.   OutputImage = result
  116.   'CLOSE' LoadImage
  117.   'CLOSE' SecondImage
  118.  
  119.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  120.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  121.   if (RC ~= 0) then do
  122.     'IE_TO_FRONT'
  123.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  124.     return '<ERROR>'
  125.   end
  126.   'CLOSE' OutputImage
  127.  
  128.   back = 'OK'
  129. return back
  130.  
  131. /* Internal procedures  ---------------------------------------------- */
  132.  
  133. /*******************************************************************/
  134. /* This is where control goes when an error code is returned by IE */
  135. /* It puts up a message saying what happened and on which line     */
  136. /*******************************************************************/
  137.  
  138. error:
  139. if RC=5 then do
  140.     IE_TO_FRONT
  141.     LAST_ERROR
  142.     'REQUEST "'||RESULT||'"'
  143. end
  144. else do
  145.     IE_TO_FRONT
  146.     LAST_ERROR
  147.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  148. end
  149.  
  150. return '<ERROR>'
  151.